package com.yangfan.screenshot.log;

import android.util.Log;

/**
 * @author : yangfan_rj
 * @date   : 2022/12/7-14:16
 * desc   :
 */
public class LogConfig {

    private LogConfig() {}

    private boolean mIsShowLog;

    private boolean mIsWriteToFile;

    private int mLogLevel;

    private String mLogFilePath;

    public boolean isShowLog() {
        return mIsShowLog;
    }

    public boolean isWriteToFile() {
        return mIsWriteToFile;
    }

    public int getLogLevel() {
        return mLogLevel;
    }

    public String getLogFilePath() {
        return mLogFilePath;
    }

    private void showLog(boolean isShow) {
        mIsShowLog = isShow;
    }

    private void writeToFile(boolean isWriteToFile) {
        mIsWriteToFile = isWriteToFile;
    }

    private void setLogLevel(int logLevel) {
        mLogLevel = logLevel;
    }

    private void setLogFilePath(String logFilePath) {
        mLogFilePath = logFilePath;
    }

    public static class Builder {

        private boolean mIsShowLog = true;

        private boolean mIsWriteToFile = true;

        private int mLogLevel = Log.VERBOSE;

        private String mLogFilePath;

        public Builder showLog(boolean isShow) {
            mIsShowLog = isShow;
            return this;
        }

        public Builder setLogLevel(int logLevel) {
            mLogLevel = logLevel;
            return this;
        }

        public Builder writeToFile(boolean isWriteToFile) {
            mIsWriteToFile = isWriteToFile;
            return this;
        }

        public Builder setLogFilePath(String logFilePath) {
            mLogFilePath = logFilePath;
            return this;
        }

        public LogConfig build() {
            LogConfig instance = new LogConfig();
            instance.setLogLevel(mLogLevel);
            instance.showLog(mIsShowLog);
            instance.writeToFile(mIsWriteToFile);
            instance.setLogFilePath(mLogFilePath);
            return instance;
        }
    }
}
